﻿#pragma once

#include "halcon_opencv.h"

extern void blob(HObject ho_image, HObject *ho_region, HTuple *hv_size);


#include <QDialog>
#include <QPushButton>
#include "QListView"
#include "QStringListModel"
#include "QFileDialog"
#include "QMessageBox"
#include "QApplication"
#include "QVBoxLayout"
#include <QDesktopWidget>
#include <QLibrary>
#include <QApplication>
#include <QLabel>
#include <QComboBox>
#include "QListView"
#include "QStringListModel"
#include "QLineEdit"
#include "QSpinBox"
#include "QRadioButton"
#include <QSettings>

#include "commonfunction.h"


using namespace std;

#include "qt_graphics_view.h"

#include "function_blob_size.h"
#include "function_blob_9006.h"

#include "function_dl_line_9007.h"
#include "function_dl_3.h"

#include "function_dl.h"

#include "function_dl_top.h"

#include <QSettings>

class Function:public QDialog
{
public:

	
    int m_camera_index = 0;

    QString m_dir = "";

    QSettings* m_qsettings;



    FunctionBlobSize* m_function_blob_size = nullptr;
    QPushButton* m_pushbutton_blob_size = nullptr;
    QComboBox* m_qcombobox_unuse_use_blob_size = nullptr;
    int m_unuse_use_blob_size = 0;

    FunctionScan* m_function_scan = nullptr;
    QPushButton* m_pushbutton_scan = nullptr;
    QComboBox* m_qcombobox_unuse_use_scan = nullptr;
    int m_unuse_use_scan = 0;

    /*FunctionBlob9007* m_function_blob_9007 = nullptr;
    QPushButton* m_pushbutton_blob_9007 = nullptr;
    QComboBox* m_qcombobox_unuse_use_blob_9007 = nullptr;
    int m_unuse_use_blob_9007 = 0;*/


    Detection_dl*       m_function_dl= nullptr;
    QPushButton* m_pushbutton_dl= nullptr;
    QComboBox* m_qcombobox_unuse_use_dl= nullptr;
    int m_unuse_use_dl = 0;


    FunctionDLLine9007*       m_function_dl_line_9007= nullptr;
    QPushButton* m_pushbutton_dl_line_9007= nullptr;
    QComboBox* m_qcombobox_unuse_use_dl_line_9007= nullptr;
    int m_unuse_use_dl_line_9007 = 0;

    DetectionDLTop*       m_function_dl_top= nullptr;
    QPushButton* m_pushbutton_dl_top= nullptr;
    QComboBox* m_qcombobox_unuse_use_dl_top= nullptr;
    int m_unuse_use_dl_top = 0;


    Detection_dl_3*       m_function_dl_3= nullptr;
    QPushButton* m_pushbutton_dl_3= nullptr;
    QComboBox* m_qcombobox_unuse_use_dl_3= nullptr;
    int m_unuse_use_dl_3 = 0;

    Mat m_image ;
    QString m_path_para = "para.json";
    QString m_section   = "";
    QtQGraphicsView* m_view ;
    QGraphicsPixmapItem* pixmapItem;

    QPushButton* m_pushbutton_load_image;
    QPushButton* m_pushbutton_load_dir;
    QListView* m_listview;
    QStringListModel* m_listview_model;


    QPushButton* m_pushbutton_blob_math;
    Mat image_out;
//    QComboBox* m_qcombobox_unuse_use;
    int m_unuse_use_function = 1;


    QComboBox* m_qcombobox_save_wrong;
    int m_save_wrong = 0;

    QComboBox* m_qcombobox_save_right;
    int m_save_right = 0;

    /*QLabel * m_qlabel_save_jpg_png;
    QComboBox* m_qcombobox_save_jpg_png;
    int m_save_jpg_png= 0;*/


    QComboBox* m_qcombobox_save_wrong_label;
    int m_save_wrong_label = 0;

    QComboBox* m_qcombobox_save_right_label;
    int m_save_right_label = 0;

    QPushButton* m_pushbutton_save_load_image;
    QPushButton* m_pushbutton_show_orign_image;
    QPushButton* m_pushbutton_detection;
	QPushButton* m_pushbutton_detection2;
    QPushButton* m_pushbutton_save_parameter;
    QPushButton* m_pushbutton_return;

    Mat m_image_show;

    int m_size=0;
    HObject m_region;
public:
    explicit Function(QDialog* parent, QString dir, int camera_index);

    bool detection(Mat image_in, int index, QString& message);


	

    void detectionImage();
	//void detectionImage2();

    void draw(Mat image_in, Mat& image_out);


    void listViewClick(const QModelIndex& model_index);


	void loadParameter(QString path_in, QString section);

	void saveParameter();

};
#pragma execution_character_set("utf-8")
